<?php 
/***Create By fu**/
namespace app\api\controller\v1;

use app\api\model\Banner as BannerModel;
use app\api\validate\IDCollection;
use app\api\validate\IDMustBePostiveInt;
use app\lib\exception\ThemeException;
use app\api\model\Theme as ThemeModel;
 
/**
* 
*/
class Theme
{
	/**专题列表
	 * @url /theme?ids=id1,id2...
	 * @http GET
	 * @return 一组theme模型
	 */
	public function getSimpleList($ids=''){
		 
		(new IDCollection)->goCheck();
		$ids = explode(',', $ids);
	    $result = ThemeModel::with('topicImg,headImg')
	              ->select($ids);
	    
	    //当database返回为数据集后不能简单判空了，要使用模型自带的检查空数据集的方法
		if($result->isEmpty())throw new ThemeException();
 
	    return $result;
       
	}
	/**专题详情
	 *
	 */
	public function getComplexOne($id)
	{
		(new IDMustBePostiveInt)->goCheck();
		
		$theme = ThemeModel::getThemeWithProducts($id);
        
        if(!$theme)throw new ThemeException();
		return $theme;
	}
 
}




 ?>